<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>系统登录</title>
    <link type="text/css" href="../layui/css/layui.css">
</head>
<body class="login_bg">
    <header class="loginHeader">
        <h1>登录管理系统</h1>
    </header>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">输入框</label>
            <div class="layui-input-block">
                <input type="text" name="username" id="username" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码框</label>
            <div class="layui-input-inline">
                <input type="password" name="password"  id="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo" id="doLogin">登录</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
        </form>
    <script src="../js/jquery-1.12.4.js" type="text/javascript" charset="UTF-8"></script>
    <script>
        $(function () {
            $("#doLogin").click(function () {
                $.ajax({
                    url: "login",
                    dataType:"JSON",
                    data
                        :
                        {username:$("#username").val() ,password:$("#password").val()},
                    type
                        :
                        "post",
                    success
                        :

                        function (data) {
                            if(data=="true"){
                                location.href="index.html";
                            }else {
                                layer.msg('账号或者密码错误', {
                                    icon: 1,
                                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                });

                            }

                        }
                });
            });
        });

    </script>


</body>

</html>